<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="str" uri="/WEB-INF/config/tld/string-util.tld" %>
<jsp:include page="../include/header.jsp" />
<script type="text/javascript" src="<c:url value='/htmlRes/js/jquery.form.js'/>"></script>
<script type="text/javascript" src="<c:url value='/htmlRes/js/fileUpload.js'/>"></script>
<script type="text/javaScript">
<!--
	/* pagination 페이지 링크 function */
	function listPage(){
		$('#writeForm').attr('action', '<c:url value="/task/taskList.do"/>');
		$('#writeForm').submit();
	}
	
	function saveFormPage() {
		$('#writeForm').attr('action', '<c:url value="/task/taskSave.do"/>');
		$('#writeForm').submit();
	}
	
	var fileOtions;
	$(document).ready(function(){
		fileOtions = {fileObjId:"file",fileType:"xls",toObj:"sto_task_file",showFileInfo:"fileInfo",oriNameUsed:true};
	});
	
	function fileDelete(){
		var taskKey = $.trim($('#sto_task_key').val());
		if(taskKey==''){
			return;
		}
		$.ajax({
			type : "POST" ,
			url : "<c:url value='/task/deleteAttachFile.do'/>",
			dataType: 'html',
			data : 'sto_task_key='+taskKey,
			success: function(data) {
				if(data == "true"){
					$('#sto_task_file').val('');
					$('#fileInfo').html('');
				}else{
					alert("파일 삭제 실패!");
				};
			}, 
			error: function(request, status, err) {
				alert(request.status);
			}
		});
	}
-->
</script>
<!-- contents s -->
<div class="container" id="container">
	<span class="round lt">&nbsp;</span>
	<span class="round rt">&nbsp;</span>
	<span class="round lb">&nbsp;</span>
	<span class="round rb">&nbsp;</span>
	<div class="container_area">
	<form name="writeForm" id="writeForm" action="<c:url value="/task/taskWriteForm.do"/>" method="post">
		<input type="hidden" name="sto_task_file" id="sto_task_file" value="${resultVO.sto_task_file }"/>
		<input type="hidden" name="sto_task_key" id="sto_task_key" value="${resultVO.sto_task_key }"/>
	
		<h2 class="tit_h2">업무연락 등록</h2>
		<jsp:include page="../include/navi.jsp" />
		<div class="table_wrap">
			<table summary="현장 선택 안내입니다" class="table_write">
				<caption>현장 선택</caption>
				<colgroup> <!-- D : col width로 테이블 넓이 조절 -->
					<col width="15%" />
					<col width="85%" />
				</colgroup>
				<tbody>
					<tr>
						<th scope="row">현장 선택</th>
						<td class="alL">
							<ul class="check_area">
							<c:if test="${empty resultVO.taskServiceVOList }">
								<c:forEach var="result" items="${serviceareaList }" varStatus="status">
									<li><input type="checkbox" title="${result.ssa_area_name }" name="taskServiceVOList[${status.count-1 }].sts_area_key" value="${result.ssa_area_key }" /> ${result.ssa_area_name }</li>
								</c:forEach>
							</c:if>
							<c:if test="${not empty resultVO.taskServiceVOList }">
								<c:forEach var="result" items="${resultVO.taskServiceVOList }" varStatus="status">
									<li><input type="checkbox" title="${result.ssa_area_name }" name="taskServiceVOList[${status.count-1 }].sts_area_key" value="${result.ssa_area_key }" <c:if test="${!empty result.sts_task_key }">checked="checked"</c:if>/> ${result.ssa_area_name }</li>
								</c:forEach>
							</c:if>
							</ul>
						</td>
					</tr>
					
				</tbody>
			</table>
		</div>

		<div class="table_wrap"><!-- D : table은 div table_wrap 싸고감 -->
			<table summary="설비현황 목록" class="table_write">
				<caption>설비현황 목록</caption>
				<colgroup> <!-- D : col width로 테이블 넓이 조절 -->
					<col width="15%" />
					<col width="85%" />
				</colgroup>
				<tbody>
					<tr>
						<th scope="row"><label for="tit">제목</label></th>
						<td class="alL"><input type="text" id="sto_task_title" name="sto_task_title" class="width_50" value="${resultVO.sto_task_title }"/></td>
					</tr>
					<tr>
						<th scope="row">첨부파일</th>
						<td class="alL"><input type="file"  name="file" id="file" title="첨부파일 선택" class="width_40" onchange="uploadFile(fileOtions);" />
						<span id="fileInfo">
							<c:if test="${not empty resultVO.sto_task_file }">
								<c:set var="saveFile" value="${fn:split(resultVO.sto_task_file,'**')}" />
								<a href="<c:url value='/fileDownload.do'/>?fileInfo=${resultVO.sto_task_file}" onclick="fileDown();return false;" class="file_down ${str:getFileType(saveFile[0])}" >${saveFile[1] }(${saveFile[2]})</a>
								<a href="#fileDelete" id="fileDelete" class="btn_gy" onclick="fileDelete();return false;">파일 삭제</a>
							</c:if>
						</span></td>
					</tr>
                          <tr>
						<th scope="row">내용</th>
						<td class="alL"><textarea title="이력사항을 입력하세요" id="sto_task_cont" name="sto_task_cont" row="" col="">${resultVO.sto_task_cont }</textarea></td>
					</tr>							
				</tbody>
			</table>
		</div>
		
		<div class="btn_bbs">
			<a href="<c:url value='/task/taskList.do' />" onclick="listPage();return false;" class="btn_wh">목록</a>
			<a href="<c:url value="/task/taskSave.do"/>" class="btn_re" onclick="saveFormPage();return false;">저장</a>
		</div>
		<!-- 검색조건 유지 -->
		<input type="hidden" name="pageIndex" id="pageIndex" value="${resultVO.pageIndex }"/>
	</form>
	</div><!--//container_area-->
</div>

<!-- contents e -->


	
<jsp:include page="../include/fileUpload.jsp" flush="true"/>
<jsp:include page="../include/fileDownload.jsp" flush="false">
	<jsp:param name="fileInfo" value="${resultVO.sto_task_file}" />
</jsp:include>
<jsp:include page="../include/footer.jsp" flush="true"/>
